<%--
  Created by IntelliJ IDEA.
  User: 14122
  Date: 2022/8/18
  Time: 20:40
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/pintuer.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/admin.css">
    <script src="${pageContext.request.contextPath}/js/jquery.js"></script>
    <script src="/${pageContext.request.contextPath}js/pintuer.js"></script>
</head>
<body>


<li>

    <form action="${pageContext.request.contextPath}/employee/findEmployeeByName" method="post">
        <input type="text" name="username" value="">
        <input type="submit" value="查找">
    </form>
</li>


<table class="table table-hover text-center">
    <tr>
        <th width="120">ID</th>
        <th>用户名</th>
        <th>姓名</th>
        <th>密码</th>
        <th>性别</th>
        <th>电话</th>
        <th>地址</th>
        <th>邮箱</th>
        <th>状态</th>
        <th>操作</th>
    </tr>

   <c:forEach items="${page.list}" var="employee">
       <tr>
           <td><input type="checkbox" name="id[]" value="1" />${employee.empId}</td>
           <td>${employee.userName}</td>
           <td>${employee.name}</td>
           <td>${employee.password}</td>
           <c:if test="${employee.gender==1}">
               <td>男</td>
           </c:if>

           <c:if test="${employee.gender==0}">
               <td>女</td>
           </c:if>

           <td>${employee.phone}</td>
           <td>${employee.address}</td>
           <td>${employee.email}</td>

           <c:if test="${employee.deleted==0}">
               <td>在职</td>
           </c:if>
           <c:if test="${employee.deleted==1}">
               <td>未在职</td>
           </c:if>
           <td><a type="button" class="button border-main" href="${pageContext.request.contextPath}/employee/updateEmployeePage?emp_id=${employee.empId}"><span class="icon-edit"></span>修改</a>
               <a class="button border-red" href="${pageContext.request.contextPath}/employee/deleteEmployee?emp_id=${employee.empId}" onclick="return del(17)"><span class="icon-trash-o"></span> 删除</a></td>
       </tr>
   </c:forEach>




<%--            分页实现....................................................--%>


            <tr>
                <td colspan="8"><div class="pagelist">
<%--                    点击首页,跳转到第一页--%>
                    <a href="${pageContext.request.contextPath}/employee/employeePage?pageNum=1">首页</a>
<%--   点击上一页时, 如果已经在第一页,就跳转第一页--%>
    <c:if test="${page.pageNum==1}">
        <a href="${pageContext.request.contextPath}/employee/employeePage?pageNum=1">上一页</a>
    </c:if>
<%--    点击上一页时,如果当前页不是第一页,就跳转上一页--%>
    <c:if test="${page.pageNum!=1}">
        <a href="${pageContext.request.contextPath}/employee/employeePage?pageNum=${page.prePage}">上一页</a>
    </c:if>

    <c:forEach items="${page.navigatepageNums}" var="num">

        <c:if test="${page.pageNum==num}">
            <span class="current">${num}</span>
        </c:if>

        <c:if test="${page.pageNum != num}">
            <a href="${pageContext.request.contextPath}/employee/employeePage?pageNum=${num}">${num}</a>

        </c:if>
    </c:forEach>
    

<%--    当点击下一页时,若在最后一页,就跳转到最后一页--%>
<%--    若没在最后一页跳转到下一页--%>
<%--    ${page.pages}表示最后一页--%>

    <c:if test="${page.pageNum!=page.pages}" >
        <a href="${pageContext.request.contextPath}/employee/employeePage?pageNum=${page.nextPage}">下一页</a>
    </c:if>
    <c:if test="${page.pageNum==page.pages}" >
        <a href="${pageContext.request.contextPath}/employee/employeePage?pageNum=${page.pages}">下一页</a>
    </c:if>

<%--    点击尾页跳转到尾页--%>
                    <a href="${pageContext.request.contextPath}/employee/employeePage?pageNum=${page.pages}">尾页</a>

        </table>



</form>
<script type="text/javascript">

    function del(id) {
        if (confirm("您确定要删除吗?")) {

        }
    }

    $("#checkall").click(function () {
        $("input[name='id[]']").each(function () {
            if (this.checked) {
                this.checked = false;
            } else {
                this.checked = true;
            }
        });
    })

    function DelSelect() {
        var Checkbox = false;
        $("input[name='id[]']").each(function () {
            if (this.checked == true) {
                Checkbox = true;
            }
        });
        if (Checkbox) {
            var t = confirm("您确认要删除选中的内容吗？");
            if (t == false) return false;
        } else {
            alert("请选择您要删除的内容!");
            return false;
        }
    }

</script>
</body>
</html>
